chore: replace per-site @nowarn with scoped -Wconf in codegen#648
Draft
He-Pin wants to merge 1 commit intoapache:mainfrom
Draft
chore: replace per-site @nowarn with scoped -Wconf in codegen#648He-Pin wants to merge 1 commit intoapache:mainfrom
He-Pin wants to merge 1 commit intoapache:mainfrom
Conversation
Remove the `@nowarn("msg=is never used")` annotation from
`CodeGenerator.registerExtensions` in the Scala-2.12 source tree and
replace it with a precisely-scoped `-Wconf` compiler option in
`project/Common.scala`.
The `registerExtensions` method is a trait default implementation whose
`registry: ExtensionRegistry` parameter goes unused. Scala 2.12's
`-Ywarn-unused` fires on this; the per-site annotation silenced it.
The new `-Wconf:src=.*/grpc/gen/CodeGenerator\.scala:msg=is never used`
option targets only that single file and only the "is never used" message,
keeping the full warning signal everywhere else. The Scala-2.13+ counterpart
file has never needed an annotation.
Upstream commit: akka/akka-grpc@46bd59ff
Upstream PR: akka/akka-grpc#1699
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
In the Scala 2.12 codegen module,
@nowarn("cat=unused-params")was applied per-site to silence a compiler warning about an unused parameter inregisterExtensions. This annotation approach is fragile — it must be remembered at every call site and couples source files to specific warning categories.Modification
@nowarnannotation fromCodeGenerator.scala(Scala 2.12 version)-Wconf:src=.*/grpc/gen/CodeGenerator\.scala:msg=is never used:silenttoproject/Common.scala, targeting only the specific file and message patternResult
The unused parameter warning is suppressed via compiler configuration instead of per-site annotations. This is more maintainable, less intrusive, and follows Scala compiler best practices.
References